import type { PageReq } from '../common/commonApi'
import { useApi } from '@/composables/useApi'

export interface CodeGenerateResult {
  id: number
  projectName: string
  templateId: number
  createTime: string
  fileList: CodeGenerateFile[]
}

export interface CodeGenerateResultQuery extends PageReq {
  id?: number
  projectName?: string
}

export interface CodeGenerateFile {
  id: number
  resultId: number
  templateId: number
  templateFileId: number
  fileName: string
  filePath: string
  content: string
  success: boolean
}

export interface CodeGenerateFileTreeNode {
  key: string
  label: string
  file?: CodeGenerateFile
  children?: CodeGenerateFileTreeNode[]
}

export interface CodeGenerateCmd {
  projectName: string
  templateId: number
}

const basePath = '/code/generate'
export const codeGenerateApi = {
  generate: useApi<CodeGenerateCmd, any>(`${basePath}`).postDownload,
}
